<%@ taglib uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" prefix="dsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>  

<dsp:page>
	<dsp:droplet name="/atg/commerce/inventory/InventoryLookup">
		<dsp:param param="skuid" name="itemId" />
		<dsp:param value="false" name="useCache" />
		<dsp:oparam name="output">
			<dsp:getvalueof var="availabilityDate" param="inventoryInfo.availabilityDate"></dsp:getvalueof>
			<dsp:droplet name="/atg/dynamo/droplet/Switch/">
				<dsp:param name="value" param="inventoryInfo.availabilityStatus"/>
				
				<!-- in stock -->
				<dsp:oparam name="1000">
					<dsp:getvalueof var="stockLevel" param="inventoryInfo.stockLevel"></dsp:getvalueof>
					<dsp:getvalueof var="stockThreshold" param="inventoryInfo.stockThreshold"></dsp:getvalueof>
					<c:choose>
						<c:when test="${stockLevel > stockThreshold}">
							Item in stock
						</c:when>
						<c:otherwise>
							Only ${stockLevel} amount in stock
						</c:otherwise>
					</c:choose>
				</dsp:oparam>
				
				<!-- out of stock -->
				<dsp:oparam name="1001">
					Sorry. Item is Out of Stock. Please try our related products.
				</dsp:oparam>
				
				<!-- preorderable -->
				<dsp:oparam name="1002">
					<dsp:getvalueof var="preOrderLevel" param="inventoryInfo.preorderLevel"></dsp:getvalueof>
					<dsp:getvalueof var="preOrderThreshold" param="inventoryInfo.preorderThreshold"></dsp:getvalueof>
					<c:choose>
						<c:when test="${preOrderLevel > preOrderThreshold}">
							Item preordered. Estimated availability for shipment: 
							<fmt:formatDate value="${availabilityDate}" pattern="yyyy/MM/dd" type="both"/>
						</c:when>
						<c:otherwise>
							Item preordered. Estimated availability for shipment: <fmt:formatDate value="${availabilityDate}" pattern="yyyy/MM/dd" type="both"/>. Order quickly, preordered stock almost out.
						</c:otherwise>
					</c:choose>
				</dsp:oparam>	
				
				<!-- backorderable -->		
				<dsp:oparam name="1003">
					<dsp:getvalueof var="backOrderLevel" param="inventoryInfo.backorderLevel"></dsp:getvalueof>
					<dsp:getvalueof var="backOrderThreshold" param="inventoryInfo.backorderThreshold"></dsp:getvalueof>
					<c:choose>
						<c:when test="${backOrderLevel > backOrderThreshold}">
							Item backordered. Estimated availability for shipment: <fmt:formatDate value="${availabilityDate}" pattern="yyyy/MM/dd" type="both"/>.
						</c:when>
						<c:otherwise>
							Item backordered. Estimated availability for shipment: <fmt:formatDate value="${availabilityDate}" pattern="yyyy/MM/dd" type="both"/>. Order quickly, backordered stock almost out.
						</c:otherwise>
					</c:choose>					
				</dsp:oparam>		
			</dsp:droplet>
		</dsp:oparam>
	</dsp:droplet>
</dsp:page>
